//==================================================================
/// vehicle.cpp
///
/// Created by Davide Pasca - 2009/10/5
/// See the file "license.txt" that comes with this project for
/// copyright info. 
//==================================================================

#include "stdafx.h"
#include "vehicle.h"

//==================================================================
vehicle::vehicle( sprite *pSprt, float start_x, int start_pos, float speed, bool check_collision )
{
	mpSprt = pSprt;
	mStartPos = start_pos;
	mPos = mStartPos;
	mX = start_x;
	mSpeed = speed;
	mCheckCollision = check_collision;
	mpNext = NULL;
}

vehicle::vehicle( sprite *pSprt, float start_x, int start_pos, float speed )
{
	mpSprt = pSprt;
	mStartPos = start_pos;
	mPos = mStartPos;
	mX = start_x;
	mSpeed = speed;
	mCheckCollision = true;
	mpNext = NULL;
}

void vehicle::animate( float far_pos )
{
	if ( far_pos >= mStartPos )
		mPos += mSpeed;
	//else
	//	mPos = pos;
}

bool vehicle::is_drawable() const
{
	if ( mPos >= mStartPos )
		return true;

	return false;
}

void vehicle::draw( graphics &g, int frame, int x, int y, float scale ) const
{
	mpSprt->draw( g, frame * 10, x, y, scale );
}